import { defineComponent } from 'vue'
import type { PropType } from 'vue'
import { AuthOperationType } from '@/router/const'
import { useUserStore } from '@/stores/user'
import { downloadImportTemplate } from '@/api/pscrm/customer'

/**
 * 登录 注册
 */
export default defineComponent({
  name: 'loginComponent',
  props: {
    type: {
      type: String as PropType<AuthOperationType>,
      required: true,
    },
  },
  setup(props) {
    const { login } = useUserStore()

    const downloadTemplate = () => {
      const params = {
        companyId: '1876',
        businessType: 0,
        teamId: '1876',
      }
      downloadImportTemplate(params)
    }

    return () => (
      <>
        <div>我是{props.type === AuthOperationType.Login ? '登录' : '注册'}界面</div>
        <a-button type="primary" onClick={login}>
          登录
        </a-button>
        <a-button type="primary" onClick={downloadTemplate}>
          下载客户模板
        </a-button>
      </>
    )
  },
})
